<?php 
header("content-type:text/html;charset=utf-8");
$redis=new Redis();
$redis->connect("127.0.0.1","6379");
$db=new PDO("mysql:host=127.0.0.1;dbname=zice;charset=utf8",'root','root');
$tel=$_POST['tel'];
$code=$_POST['code'];
$name=$_POST['name'];
$pwd=$_POST['pwd'];
$time=date("Y-m-d H:i:s");
$rediscode=$redis->get("code".$tel);
if($rediscode){
	if($rediscode==$code){
		$sql="insert into ceshi values('','$name','$pwd','$tel',1,'$time')";
		$res=$db->exec($sql);
		if($res){
			$data=array('code'=>0,"msg"=>"注册成功");
		}	else{
			$data=array('code'=>2,"msg"=>"注册失败");
		}
	}else{
		$data=array('code'=>1,"msg"=>"验证码错误");
	}
}else{
	$data=array('code'=>3,"msg"=>"验证码失效");
}

echo json_encode($data);







 ?>